package com.rran.study.designpattern.behavioral.observer.listener.app;

import com.rran.study.designpattern.behavioral.observer.event.app.OrderEvent;
import com.rran.study.designpattern.behavioral.observer.model.OrderData;

/**
 * @author yy
 * @Type AppSendMsgListener.java
 * @Desc OrderEvent监听者--发短信
 * @date 2020/7/21 19:46
 */
public class AppSendMsgListener implements AppListener<OrderEvent> {
    @Override
    public void applicationEvent(OrderEvent event) {
        this.sendMsg(event.getSource());
    }

    /**
     * 发送短信
     */
    private void sendMsg(OrderData orderData) {
        System.out.println("短信观察者：发送成功，短信内容：购买商品数为" + orderData.getMoney()
                + "总共消费了：" + orderData.getBuyCount() + "件");
    }
}
